package com.metamech.jabber.xml;

import org.apache.log4j.Logger;

import com.metamech.jabber.Session;

public class ProcessThread extends Thread {
	private static Logger logger=Logger.getLogger(ProcessThread.class);
	static Session session;
	PacketQueue packetQueue;

	public ProcessThread(PacketQueue queue, Session session){
		packetQueue = queue;
		this.session = session;
	}

	public void run(){
		logger.info("Process Thread is Running");
		try {
			// Processing incoming
			JabberInputHandler handler = new JabberInputHandler(packetQueue);
			handler.process(session);
		} catch (Exception ex){
			logger.error("ProcessThread: ", ex);
			if (session.getStatus() > Session.CONNECTED){
				try {
					session.disconnect();
				} catch (Exception eex){
					
				}
			}
		}
	}
}
